from rest_framework import serializers
from apps.recruit.models import Recruit,Enterprise,City

class EnterpriseSerializerSimple(serializers.ModelSerializer):

    class Meta:
        model = Enterprise
        fields = ('id', 'name','labels','logo','recruits','summary')


class RecruitSerializerSimple(serializers.ModelSerializer):
    enterprise = EnterpriseSerializerSimple(read_only=True)

    class Meta:
        model = Recruit
        fields = ('id', 'jobname','salary','condition','education','type','city','createtime','enterprise','labels')


#企业详情
class EnterpriseSerializer(serializers.ModelSerializer):
    recruits = RecruitSerializerSimple(many=True, read_only=True)

    class Meta:
        model = Enterprise
        fields = "__all__"



class RecommendJobSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializerSimple(read_only=True)

    class Meta:
        model=Recruit
        fields=('id', 'jobname','salary','condition','education','type','city','createtime','enterprise','labels')


#热门职业
class HotEnterpriseSerializer(serializers.ModelSerializer):

    class Meta:
        model=Enterprise
        fields='__all__'


#职位详情
class DetailSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializer(read_only=True)

    class Meta:
        model=Recruit
        fields='__all__'


#热门城市
class HotCitySerializer(serializers.ModelSerializer):

    class Meta:
        model=City
        fields='__all__'




